<template>
  <div>
    <!--面包屑导航-->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/Home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item><a href="/">用户管理</a></el-breadcrumb-item>
      <el-breadcrumb-item>用户列表</el-breadcrumb-item>
      <el-breadcrumb-item>用户详情</el-breadcrumb-item>
    </el-breadcrumb>

    <!--内容区-->
    <el-card class="box-card">
      <!--搜索与添加区域-->
      <el-row :gutter="20">
        <el-col :span="6">
          <el-input placeholder="请输入内容" v-model="input3" class="input-with-select">
            <el-button slot="append" icon="el-icon-search"></el-button>
          </el-input>
        </el-col>
        <el-col :span="6">
          <div class="grid-content bg-purple">
            <el-button type="success">成功按钮</el-button>
          </div>
        </el-col>
      </el-row>
      <!--用户列表区域-->
      <el-row>
        <el-table :data="uselist" style="width: 100%" stripe border>
          <el-table-column type="index">
          </el-table-column>
          <el-table-column prop="username" label="姓名" width="180">
          </el-table-column>
          <el-table-column prop="email" label="邮箱" width="180">
          </el-table-column>
          <el-table-column prop="mobile" label="电话">
          </el-table-column>
          <el-table-column prop="role_name" label="角色">
          </el-table-column>

          <el-table-column label="状态">
           <template slot-scope="scope">
             <el-switch v-model="scope.row.mg_state" @change="userStateChanged(scope.row)"></el-switch>
           </template>
          </el-table-column>

          <el-table-column label="操作">
           <template slot-scope="scope">
              <el-tooltip class="item" effect="dark" circle content="微微好" placement="top-end">
                   <el-button type="primary" icon="el-icon-edit"  size="mini"></el-button>
                 </el-tooltip>
              <el-tooltip class="item" effect="dark" circle content="微微好" placement="top-end">
                   <el-button type="success" icon="el-icon-share" size="mini"></el-button>
                 </el-tooltip>
                 <el-tooltip class="item" effect="dark" circle content="微微好" placement="top-end">
                     <el-button type="info" icon="el-icon-delete" size="mini"></el-button>
                    </el-tooltip>
           </template>
          </el-table-column>
        </el-table>
      </el-row>

    </el-card>


  </div>
</template>

<style scoped>

</style>
<script>
  export default {
    data() {
      return {
        input3: '',

        //获取用户列表的参数对象
        queryInfo: {
          query: '',
          pagenum: 1,
          pagesize: 2
        },
        uselist: [],
        //总数据条数
        totle: 0


      }
    },

    created() {
      this.getUserList()
    },
    methods: {

      async getUserList() {
        const {
          data: res
        } = await this.$http.get('users', {
          params: this.queryInfo
        })

        if (res.meta.status !== 200) {
          return this.$message.error("获取用户列表失败！")
        }
        //console.log(res)
        this.uselist = res.data.users
        this.totle = res.data.totle


      },



    }



  }
</script>
